import 'package:accumulation/function/scan_page.dart';
import 'package:accumulation/function/web_view.dart';
import 'package:accumulation/style/right_top_triangle.dart';
import 'package:accumulation/view/custom_list_page.dart';
import 'package:accumulation/widget/time_selector/time_selector_page.dart';
import 'package:accumulation/widget/trace_line.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/screenutil.dart';

import 'function/camera_gallery.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    ScreenUtil.init();
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Accumulation'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: SingleChildScrollView(
        child: Column(
          children: <Widget>[
            Padding(
              padding: EdgeInsets.symmetric(vertical: 10.0),
              child: Row(
                children: <Widget>[
                  Expanded(
                    flex: 1,
                    child: Divider(
                      color: Colors.grey,
                    ),
                  ),
                  Text("必备组件"),
                  Expanded(
                    flex: 1,
                    child: Divider(
                      color: Colors.grey,
                    ),
                  )
                ],
              ),
            ),
            Wrap(
              alignment: WrapAlignment.center,
              spacing: 10.0,
              children: <Widget>[
                FlatButton(
                  color: Colors.blue,
                  shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10.0)),
                  child: Text("带空页面的列表", style: TextStyle(color: Colors.white)),
                  onPressed: (){
                    Navigator.of(context).push(MaterialPageRoute(builder: (context) {
                      return CustomListPage();
                    }));
                  },
                ),
              ],
            ),
            Padding(
              padding: EdgeInsets.symmetric(vertical: 10.0),
              child: Row(
                children: <Widget>[
                  Expanded(
                    flex: 1,
                    child: Divider(
                      color: Colors.grey,
                    ),
                  ),
                  Text("常见组件"),
                  Expanded(
                    flex: 1,
                    child: Divider(
                      color: Colors.grey,
                    ),
                  )
                ],
              ),
            ),
            Wrap(
              alignment: WrapAlignment.center,
              spacing: 10.0,
              children: <Widget>[
                FlatButton(
                  color: Colors.blue,
                  shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10.0)),
                  child: Text("物流跟踪线", style: TextStyle(color: Colors.white),),
                  onPressed: (){
                    Navigator.of(context).push(MaterialPageRoute(builder: (context) {
                      return TraceLinePage();
                    }));
                  },
                ),
                FlatButton(
                  color: Colors.blue,
                  shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10.0)),
                  child: Text("仿叮咚买菜的时间段选择", style: TextStyle(color: Colors.white),),
                  onPressed: (){
                    Navigator.of(context).push(MaterialPageRoute(builder: (context) {
                      return TimeSelectorPage();
                    }));
                  },
                ),
              ],
            ),
            Padding(
              padding: EdgeInsets.symmetric(vertical: 10.0),
              child: Row(
                children: <Widget>[
                  Expanded(
                    flex: 1,
                    child: Divider(
                      color: Colors.grey,
                    ),
                  ),
                  Text("基础功能"),
                  Expanded(
                    flex: 1,
                    child: Divider(
                      color: Colors.grey,
                    ),
                  )
                ],
              ),
            ),
            Wrap(
              alignment: WrapAlignment.center,
              spacing: 10.0,
              children: <Widget>[
                FlatButton(
                  color: Colors.blue,
                  shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10.0)),
                  child: Text("相机相册", style: TextStyle(color: Colors.white),),
                  onPressed: (){
                    Navigator.of(context).push(MaterialPageRoute(builder: (context) {
                      return CameraGalleryWidget();
                    }));
                  },
                ),
                FlatButton(
                  color: Colors.blue,
                  shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10.0)),
                  child: Text("扫一扫", style: TextStyle(color: Colors.white),),
                  onPressed: (){
                    Navigator.of(context).push(MaterialPageRoute(builder: (context) {
                      return ScanPage();
                    }));
                  },
                ),
                FlatButton(
                  color: Colors.blue,
                  shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10.0)),
                  child: Text("WebView", style: TextStyle(color: Colors.white),),
                  onPressed: (){
                    Navigator.of(context).push(MaterialPageRoute(builder: (context) {
                      return WebViewPage(url: 'https://www.baidu.com/',);
                    }));
                  },
                )
              ],
            ),
            Padding(
              padding: EdgeInsets.symmetric(vertical: 10.0),
              child: Row(
                children: <Widget>[
                  Expanded(
                    flex: 1,
                    child: Divider(
                      color: Colors.grey,
                    ),
                  ),
                  Text("常见样式"),
                  Expanded(
                    flex: 1,
                    child: Divider(
                      color: Colors.grey,
                    ),
                  )
                ],
              ),
            ),
            Wrap(
              alignment: WrapAlignment.center,
              spacing: 10.0,
              children: <Widget>[
                FlatButton(
                  color: Colors.blue,
                  shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10.0)),
                  child: Text("右上角三角形", style: TextStyle(color: Colors.white),),
                  onPressed: (){
                    Navigator.of(context).push(MaterialPageRoute(builder: (context) {
                      return RightTopTrianglePage();
                    }));
                  },
                )
              ],
            ),
          ],
        ),
      )// This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}
